const express = require('express')
const router = express.Router()
//导入验证数据合法性的中间件
const expressJoi = require('@escook/express-joi')
const {
  update_userinfo_schema,
  update_password_schema,
  update_avatar_schema
} = require('../schema/user')

const userinfo_handler = require('../router_handler/userInfo')

//获取用户的基本信息
router.get('/userinfo', userinfo_handler.getUserInfo)

//更新用户基本信息处理函数
router.post('/userinfo', expressJoi(update_userinfo_schema), userinfo_handler.updateUserInfo)

//重制密码的处理函数
router.post('/updatepwd', expressJoi(update_password_schema), userinfo_handler.updatePassword)

//更新用户头像
router.post('/update/avatar', expressJoi(update_avatar_schema),userinfo_handler.updateAvatar)

module.exports = router